from pynput import keyboard
from playsound import playsound
from threading import Thread

count = 0

def onRelease(key):
    global count
    count += 1
    if count % 50 == 0:
        # 播放音频，创建线程播放音频
        # playsound('./music.mp3')
        t = Thread(target=playsound,
                   args=('./music.mp3',))
        t.start()


listener = keyboard.Listener(on_release=onRelease)
listener.start()
listener.join()



